```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTTP与RPC协议对比分析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-bg {
            background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            margin-bottom: 1.5rem;
        }
        .protocol-card {
            border-left: 4px solid;
            transition: all 0.3s ease;
        }
        .protocol-card:hover {
            transform: translateX(5px);
        }
        .dropdown-content {
            display: none;
            transition: all 0.3s ease;
        }
        .show {
            display: block;
            animation: fadeIn 0.3s;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-bg text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-6">HTTP与RPC协议对比分析</h1>
                    <p class="text-xl opacity-90 mb-8">探索现代分布式系统中的通信协议选择</p>
                    <div class="flex space-x-4">
                        <a href="#http-section" class="bg-white text-indigo-600 px-6 py-3 rounded-lg font-medium hover:bg-gray-100 transition duration-300">
                            <i class="fas fa-globe mr-2"></i> HTTP协议
                        </a>
                        <a href="#rpc-section" class="bg-indigo-800 text-white px-6 py-3 rounded-lg font-medium hover:bg-indigo-900 transition duration-300">
                            <i class="fas fa-network-wired mr-2"></i> RPC协议
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <div class="mermaid text-left">
                        graph TD
                            A[通信协议] --> B[HTTP]
                            A --> C[RPC]
                            B --> D[无状态]
                            B --> E[基于文本]
                            B --> F[广泛兼容]
                            C --> G[高效]
                            C --> H[二进制]
                            C --> I[强类型]
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-6xl py-16 px-4 md:px-0">
        <!-- Comparison Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-10 text-center">核心差异对比</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-lg p-8 protocol-card border-l-indigo-500 card-hover">
                    <div class="feature-icon bg-indigo-100 text-indigo-600">
                        <i class="fas fa-globe text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-4">HTTP协议</h3>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>无状态协议，每个请求独立</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>基于文本格式(JSON/XML/HTML)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>广泛兼容，跨平台支持</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>适用于Web应用和API调用</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white rounded-xl shadow-lg p-8 protocol-card border-l-purple-500 card-hover">
                    <div class="feature-icon bg-purple-100 text-purple-600">
                        <i class="fas fa-network-wired text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold mb-4">RPC协议</h3>
                    <ul class="space-y-3 text-gray-700">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>远程过程调用，像本地调用一样</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>二进制格式(Protobuf/Thrift)</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>高效低延迟，类型安全</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>适用于微服务和内部系统</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- HTTP Section -->
        <section id="http-section" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-indigo-100 text-indigo-600 rounded-full w-12 h-12 flex items-center justify-center mr-4">
                    <i class="fas fa-globe text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">HTTP协议详解</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
                <div class="p-6">
                    <h3 class="text-xl font-bold mb-4 text-indigo-600">定义和协议</h3>
                    <p class="text-gray-700 leading-relaxed mb-6">
                        <strong>HTTP</strong> (HyperText Transfer Protocol) 是一个无状态的应用层协议，主要用于客户端和服务器之间的通信。它基于请求-响应模式，广泛用于 Web 应用程序的数据交换。
                    </p>
                    
                    <h3 class="text-xl font-bold mb-4 text-indigo-600">数据格式</h3>
                    <p class="text-gray-700 leading-relaxed mb-6">
                        HTTP 通常使用 JSON、XML、HTML 等格式进行数据传输。请求和响应体的格式可以灵活选择，这使得它非常适合于各种不同的应用场景。
                    </p>
                    
                    <div class="bg-gray-50 p-4 rounded-lg mb-6">
                        <div class="flex justify-between items-center cursor-pointer" onclick="toggleDropdown('http-communication')">
                            <h4 class="font-medium text-gray-800">通信方式 <span class="text-indigo-600">(点击展开)</span></h4>
                            <i class="fas fa-chevron-down text-indigo-600 transition-transform duration-300" id="http-communication-arrow"></i>
                        </div>
                        <div class="dropdown-content mt-3" id="http-communication">
                            <p class="text-gray-700 leading-relaxed">
                                HTTP 是基于文本的协议，通常使用 TCP 连接。它支持各种 HTTP 方法，如 GET、POST、PUT、DELETE 等。这种设计使得 HTTP 协议非常灵活，可以适应各种不同的用例。
                            </p>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-bold mb-4 text-indigo-600">特点</h3>
                    <div class="grid md:grid-cols-2 gap-4 mb-6">
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-sync-alt text-indigo-500 mr-2"></i> 无状态
                            </h4>
                            <p class="text-gray-700 text-sm">每个请求都是独立的，服务器不会保存客户端的状态信息。</p>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-bolt text-indigo-500 mr-2"></i> 简洁
                            </h4>
                            <p class="text-gray-700 text-sm">易于理解和使用，广泛支持，适用于各种平台。</p>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-universal-access text-indigo-500 mr-2"></i> 通用
                            </h4>
                            <p class="text-gray-700 text-sm">不仅用于 Web 页面，还可以用于 API 调用和数据交换。</p>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-lock-open text-indigo-500 mr-2"></i> 开放性
                            </h4>
                            <p class="text-gray-700 text-sm">协议公开透明，易于扩展和集成。</p>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-bold mb-4 text-indigo-600">适用场景</h3>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="bg-indigo-100 text-indigo-600 rounded-full w-8 h-8 flex items-center justify-center mr-3 mt-1 flex-shrink-0">
                                <i class="fas fa-check text-sm"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">Web 应用程序</h4>
                                <p class="text-gray-700 text-sm">用于网页的加载和表单提交。</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-indigo-100 text-indigo-600 rounded-full w-8 h-8 flex items-center justify-center mr-3 mt-1 flex-shrink-0">
                                <i class="fas fa-check text-sm"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">API 调用</h4>
                                <p class="text-gray-700 text-sm">例如 RESTful API，用于客户端与服务器之间的数据交互。</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-indigo-100 text-indigo-600 rounded-full w-8 h-8 flex items-center justify-center mr-3 mt-1 flex-shrink-0">
                                <i class="fas fa-check text-sm"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">简单的数据传输</h4>
                                <p class="text-gray-700 text-sm">适用于需要传输文本或轻量数据的场景。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- RPC Section -->
        <section id="rpc-section" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="bg-purple-100 text-purple-600 rounded-full w-12 h-12 flex items-center justify-center mr-4">
                    <i class="fas fa-network-wired text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold">RPC协议详解</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-lg overflow-hidden mb-8">
                <div class="p-6">
                    <h3 class="text-xl font-bold mb-4 text-purple-600">定义和协议</h3>
                    <p class="text-gray-700 leading-relaxed mb-6">
                        <strong>RPC</strong> (Remote Procedure Call) 是一种远程过程调用协议，允许程序在不同的计算机上调用函数或过程，就像在本地调用一样。RPC 隐藏了网络通信的复杂性，使得分布式系统中的服务调用变得更简单。
                    </p>
                    
                    <h3 class="text-xl font-bold mb-4 text-purple-600">数据格式</h3>
                    <p class="text-gray-700 leading-relaxed mb-6">
                        RPC 协议可以使用各种序列化格式，如 JSON、XML、Protocol Buffers (Protobuf)、Thrift 等，来进行数据传输。这些格式通常比纯文本更紧凑，解析效率更高。
                    </p>
                    
                    <div class="bg-gray-50 p-4 rounded-lg mb-6">
                        <div class="flex justify-between items-center cursor-pointer" onclick="toggleDropdown('rpc-communication')">
                            <h4 class="font-medium text-gray-800">通信方式 <span class="text-purple-600">(点击展开)</span></h4>
                            <i class="fas fa-chevron-down text-purple-600 transition-transform duration-300" id="rpc-communication-arrow"></i>
                        </div>
                        <div class="dropdown-content mt-3" id="rpc-communication">
                            <p class="text-gray-700 leading-relaxed">
                                RPC 通常使用二进制协议进行数据传输，以提高性能和效率。它可以基于 TCP、UDP 或其他传输协议。现代 RPC 框架如 gRPC 使用 HTTP/2 作为传输协议，结合 Protocol Buffers 作为接口定义语言和数据序列化工具。
                            </p>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-bold mb-4 text-purple-600">特点</h3>
                    <div class="grid md:grid-cols-2 gap-4 mb-6">
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-tachometer-alt text-purple-500 mr-2"></i> 高效
                            </h4>
                            <p class="text-gray-700 text-sm">通过二进制协议传输数据，性能通常优于基于文本的 HTTP。</p>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-shield-alt text-purple-500 mr-2"></i> 类型安全
                            </h4>
                            <p class="text-gray-700 text-sm">可以进行强类型检查和接口定义，减少错误。</p>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-layer-group text-purple-500 mr-2"></i> 抽象化
                            </h4>
                            <p class="text-gray-700 text-sm">封装了远程调用的细节，使开发者专注于业务逻辑。</p>
                        </div>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <h4 class="font-bold text-gray-800 mb-2 flex items-center">
                                <i class="fas fa-code-branch text-purple-500 mr-2"></i> 多语言支持
                            </h4>
                            <p class="text-gray-700 text-sm">主流编程语言都有成熟的 RPC 框架实现。</p>
                        </div>
                    </div>
                    
                    <h3 class="text-xl font-bold mb-4 text-purple-600">适用场景</h3>
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-600 rounded-full w-8 h-8 flex items-center justify-center mr-3 mt-1 flex-shrink-0">
                                <i class="fas fa-check text-sm"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">微服务架构</h4>
                                <p class="text-gray-700 text-sm">服务之间的高效通信，例如使用 gRPC、Apache Thrift 等。</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-600 rounded-full w-8 h-8 flex items-center justify-center mr-3 mt-1 flex-shrink-0">
                                <i class="fas fa-check text-sm"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">内部系统</h4>
                                <p class="text-gray-700 text-sm">需要高性能和低延迟的分布式系统中的服务调用。</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <div class="bg-purple-100 text-purple-600 rounded-full w-8 h-8 flex items-center justify-center mr-3 mt-1 flex-shrink-0">
                                <i class="fas fa-check text-sm"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">高效的数据传输</h4>
                                <p class="text-gray-700 text-sm">适用于需要传输大量数据或高频调用的场景。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">总结与选择建议</h2>
            <div class="bg-white rounded-xl shadow-lg p-8">
                <div class="mermaid text-center mb-8">
                    flowchart LR
                        A[协议选择] -->|Web应用/跨平台| B(HTTP)
                        A -->|微服务/高性能| C(RPC)
                </div>
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-bold mb-4 text-indigo-600">选择 HTTP 当:</h3>
                        <ul class="space-y-3 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>需要跨平台、跨语言的标准化通信</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>浏览器与服务器之间的交互</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>需要简单易用的 API 接口</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-2"></i>
                                <span>对性能要求不是极端敏感的场景</span>
                            </li>
                        </ul>
                    </div>
                    <div>
                        <h3 class="text-xl font-bold mb-4 text-purple-600">选择 RPC 当:</h3>
                        <ul class="space-y-3 text-gray-700">
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span>系统内部服务间的高效通信</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span>对延迟和吞吐量有严格要求</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span>需要强类型接口和编译时检查</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
                                <span>使用微服务架构</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Case Studies -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">实际应用案例</h2>
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="bg-indigo-100 p-4 flex items-center justify-center h-40">
                        <i class="fas fa-shopping-cart text-indigo-600 text-5xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-bold mb-3">电子商务网站</h3>
                        <p class="text-gray-700 text-sm">使用 HTTP RESTful API 提供商品浏览、购物车和订单功能，便于Web和移动端调用。</p>
                    </div>
                </div>
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="bg-purple-100 p-4 flex items-center justify-center h-40">
                        <i class="fas fa-server text-purple-600 text-5xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-bold mb-3">微服务支付系统</h3>
                        <p class="text-gray-700 text-sm">使用 gRPC 实现服务间通信，确保支付处理的高性能和低延迟。</p>
                    </div>
                </div>
                <div class="bg-white rounded-xl shadow-lg overflow-hidden card-hover">
                    <div class="bg-gray-100 p-4 flex items-center justify-center h-40">
                        <i class="fas fa-mobile-alt text-gray-600 text-5xl"></i>
                    </div>
                    <div class="p-6">
                        <h3 class="text-xl font-bold mb-3">混合应用</h3>
                        <p class="text-gray-700 text-sm">移动应用使用 HTTP API 与后端交互，内部服务使用 RPC 进行高效通信。</p>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="container mx-auto max-w-6xl px-4 md:px-0">
            <div class="flex flex-col items-center">
                <h3 class="text-xl font-bold text-white mb-4">技术小馆</h3>
                <a href="http://www.yuque.com/jtostring" class="hover:text-white transition duration-300">
                    <i class="fas fa-external-link-alt mr-2"></i> http://www.yuque.com/jtostring
                </a>
                <div class="mt-6 flex space-x-4">
                    <a href="#" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center hover:bg-indigo-600 transition duration-300">
                        <i class="fab fa-github"></i>
                    </a>
                    <a href="#" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center hover:bg-blue-600 transition duration-300">
                        <i class="fab fa-twitter"></i>
                    </a>
                    <a href="#" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center hover:bg-red-600 transition duration-300">
                        <i class="fab fa-youtube"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });

        // Toggle dropdown function
        function toggleDropdown(id) {
            const content = document.getElementById(id);
            const arrow = document.getElementById(id + '-arrow');
            
            content.classList.toggle('show');
            arrow.classList.toggle('rotate-180');
        }
    </script>
</body>
</html>
```